<template>
  <div class="photoinfo-container">
      <h3>{{info.title}}</h3>
      <p class="subtitle">
          <span>发表时间:{{info.add_time | dateFormat('YYYY-MM-DD')}}</span>
          <span>点击：{{info.click}} 次</span>
      </p>
<hr>

<!-- 缩略图 -->
    <div class="thumbs">
      <img  v-for="(item, index) in list" :src="item.src" height="100"  :key="index">
    </div>
<!-- 图片内容 -->
      <div class="content" v-html="info.content"></div>

      <!-- 评论子组件 -->
      <cmt-box :id="id"></cmt-box>
  </div>
  
    

</template>

<script>
import comment from '../subcomponents/comment'

export default {
    data(){
        return {
             id : this.$route.params.id, //获取路由中的id
             info :{},  //图片详情
             list:[]
        }
    },
    created(){
        this.getPhotoInfo()
        this.getphotoList()
    },
    methods:{
        // 获取图片的详情
        getPhotoInfo() {
            this.$http.get("api/getimageInfo/" + this.id).then(result => {
                if (result.body.status === 0) {
                    this.info = result.body.message[0];
                }
            })
        },
        getphotoList(){
            this.$http.get('api/getthumimages/'+this.id).then(result=>{
                if(result.body.status === 0){
                    this.list = result.body.message
                }
            })
        }
    },
    components: {
    // 注册 评论子组件
    "cmt-box": comment
  }
}
</script>

<style lang="scss" scoped>
.photoinfo-container{
    padding: 3px;
    h3 {
        font-size: 14px;
        color: #26a2ff;
        text-align: center;
        margin: 15px 0;
    }
    .subtitle {
        font-size: 13px;
        display: flex;
        justify-content: space-between;
    }
    .content{
        font-size: 13px;
        line-height: 30px;
    }
    .thumbs {
        img {
            margin: 5px;
            box-shadow: 0 0 8px #999;
        }
    }
}
</style>
